<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>订单表列表</title>
<meta name="viewport"
	content="width=device-width,initial-scale=1,maximum-scale=1.0" />
<#include "/view/admin/head.html"/>
<script type="text/javascript"
	src="${base}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript"
	src="${base}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<link rel="stylesheet" type="text/css"
	href="${base}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
<script type="text/javascript"
	src="${base}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript"
	src="${base}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<link rel="stylesheet" type="text/css"
	href="${base}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
<script type="text/javascript"
	src="${base}/jstool/bootstrap-select/js/bootstrap-select.min.js"></script>
<script type="text/javascript"
	src="${base}/jstool/bootstrap-select/lang/defaults-zh_CN.min.js"></script>
<link rel="stylesheet" type="text/css"
	href="${base}/jstool/bootstrap-select/css/bootstrap-select.min.css" />

<style type="text/css">
.table-class {
	width: 90%;
	text-align: center;
	border: 1px solid #afd9ee;
	margin: 0 auto;
	margin-top: 50px;
}

.list-path {
	height: 50px;
	line-height: 50px;
	background-color: #9acfea;
}

table th {
	text-align: center;
	WORD-WRAP: break-word;
	width: 100px;
}

table thead tr {
	background-color: #9acfea;
}

.table-query {
	/*height: 40px;*/
	/*width:80px;*/
	/*text-align: center;*/
	white-space: nowrap;
	/*position: relative;*/
	float: left;
	display: inherit;
	/*display: inline;*/
}

.label-head {
	height: 60px;
	width: 100%;
}

.bs-example .input-group {
	width: 300px;
	float: left;
	margin-top: 20px;
}

.bank-label {
	width: 25px;
	float: left;
}

.label-hidden {
	display: none;
}

.panel-body {
	padding-top: 0px;
}

.input-group input[type='text'] {
	z-index: inherit;
}
/* .input-group{
            margin-top:20px;
        }*/
</style>
<script type="text/javascript">
        function query(dm){
            var href = "${base}/businorder/list?";

            href+='orderCode='+$('#orderCode').val();
                    href+='&'


            href+='businessId='+$('#businessId').val();
                    href+='&'

        	  href+='phoneNo='+$('#phoneNo').val();
        			href+='&'

            href+='status='+$('#status').val();
                    href+='&'
                    	 href+='equipmentSerNum='+$('#equipmentSerNum').val();
                    href+='&'

            href+='createTimeStart='+$('#createTimeStart').val()+"&";
            href+='createTimeEnd='+$('#createTimeEnd').val();
                 
            location.href=href;
        }
        $(function() {
            //初始化
             /*    $('#createTimeStart').datetimepicker();
                $('#createTimeEnd').datetimepicker(); */
                
                $('#createTimeStart').datetimepicker({

                	　　language: 'zh-CN',
                	　　autoclose: true,
                	　　todayHighlight: true
                	});
                  $('#createTimeEnd').datetimepicker({

                	　　language: 'zh-CN',
                	　　autoclose: true,
                	　　todayHighlight: true
                	});
                
        });
    </script>
</head>
<body>

	<#include "/view/admin/listnav.html"/>

	<div class="table-class">

		<div class="panel panel-default" style="margin: 10px 50px 10px;">
			<div class="panel-body">
				<form class="bs-example bs-example-form" role="form">

					<div class="input-group">
						<span class="input-group-addon">订单编号</span> <input type="text"
							id="orderCode" class="form-control" value="${orderCode!}"
							placeholder="请输入订单编号">
					</div>

					<span class="bank-label">&nbsp;</span>
					<div class="input-group">
						<span class="input-group-addon">收货人手机号码</span> <input type="text"
							id="phoneNo" class="form-control" value="${phoneNo!}"
							placeholder="收货人手机号码">
					</div>
					<span class="bank-label">&nbsp;</span>
					<div class="input-group">
						<span class="input-group-addon">设备号</span> <input type="text"
							name="equipmentSerNum" id="equipmentSerNum" class="form-control"
							value="${equipmentSerNum!}" placeholder="设备号">
					</div>

					<span class="bank-label">&nbsp;</span>
					<div class="input-group">
						<span class="input-group-addon">订单状态</span> <select name="status"
							id="status" class="form-control selectpicker"
							data-live-search="true">

							<option value="-1">请选择</option>
							<option value="26"<#if status?? && status==26>
								selected</#if>>未购买</option>
							<option value="27"<#if status?? && status==27>
								selected</#if>>未预付租赁</option>
								<option value="1"<#if status?? && status==1>
								selected</#if>>支付成功</option>
							<option value="25"<#if status?? && status==25>
								selected</#if>>发货处理中</option>
							<option value="13"<#if status?? && status==13>
								selected</#if>>已发货</option>
							<option value="20"<#if status?? && status==20>
								selected</#if>>已确认收货</option>
							<option value="21"<#if status?? && status==21>
								selected</#if>>已结束租赁</option>
							<option value="22"<#if status?? && status==22>
								selected</#if>>归还中</option>
							<option value="23"<#if status?? && status==23>
								selected</#if>>已归还</option>
							<option value="24"<#if status?? && status==24>
								selected</#if>>租赁中</option>
							<option value="8"<#if status?? && status==8>
								selected</#if>>已完成</option>
							<option value="8"<#if status?? && status==10>
								selected</#if>>取消订单中</option>
							<option value="8"<#if status?? && status==17>
								selected</#if>>订单已取消</option>

						</select>


					</div>

					<span class="bank-label">&nbsp;</span>


					<div class="input-group">
						<span class="input-group-addon">开始下单时间>=</span> <input type="text"
							id="createTimeStart" class="form-control" value=""
							id="createTimeStart" name="createTimeStart"
							data-date-format="yyyy-mm-dd hh:ii:ss">
					</div>
					<span class="bank-label">&nbsp;</span>
					<div class="input-group">
						<span class="input-group-addon">结束下单时间<=</span> <input type="text"
							id="createTimeEnd" class="form-control" value=""
							name="createTimeEnd" data-date-format="yyyy-mm-dd hh:ii:ss">
					</div>

					<span class="bank-label">&nbsp;</span>


					<div class="input-group" style="text-align: right;">
						<a class="btn btn-info" href="javascript:query(this)"><span
							class="glyphicon glyphicon-search"></span> 查找</a>

					</div>

				</form>
			</div>
		</div>

		<#include "/view/admin/opermsg.html"/>


		<table class="table table-hover table-bordered">

			<thead>
				<tr>
					<th>序号</th>
					<th class="label-hidden">主键</th>
					<th>订单编号</th>
					<!-- <!--  <th>购买商品名称</th> -->
					<th>总金额</th>
					<!-- <th>购买数量</th> -->
					<th>订单状态</th>
					<!-- <th>收货人联系电话</th> -->
					<th>用户</th>
					<th>联系电话</th>
					<!--   <th>下单时间</th> -->
					<th>类型</th>
					<th style="width: 20%">操作</th>
				</tr>
			</thead>
			<tbody>
				<#--
				<tr>
					<td colspan="9" style="text-align: left; color: red;">已售量：${allSoldOut?default(0)};
						<span style="width: 50px;">&nbsp;</span>
						已售金额：${salesAmount?default("0")}元;
					</td>
				</tr>
				--> <#list pagination.list as c>
				<tr>
					<td>${(pagination.pageNo-1)*pagination.pageSize+1+c_index}</td>
					<td class="label-hidden">${c.id!}</td>
					<th>${c.orderCode!}</th>
					<!--    <th>${c.commodityName!}</th> -->
					<th>${c.totalAmount!}</th>
					<!-- <th>${c.amount!}</th> -->
					<th>
					<#if c.status ??> 
					<#if c.status==26> <span class="label label-default">未购买</span></#if>
					 <#if c.status==27> <span class="label label-default">未预付租赁</span></#if>
					  <#if c.status==1> <span class="label label-default">支付成功</span></#if>
					<#if c.status==25> <span class="label label-default">发货处理中</span></#if>
					<#if c.status==13> <span class="label label-default">已发货</span></#if>
					<#if c.status==20> <span class="label label-default">已确认收货</span></#if>
					<#if c.status==21> <span class="label label-default">已结束租赁</span></#if>
					<#if c.status==22> <span class="label label-default">归还中</span></#if>
					<#if c.status==23> <span class="label label-default">已归还</span></#if>
					<#if c.status==24> <span class="label label-default">租赁中</span></#if>
				      <#if c.status==8> <span class="label label-success">已完成</span></#if>
				    <#if c.status==10> <span class="label label-warning">取消订单中</span></#if>
					<#if c.status==17> <span class="label label-danger">订单已取消</span></#if>
					
						<#else> -- </#if>


					</th>
					<!-- <th>${c.phoneNo!}</th> -->
					<th><#if c.businOrderUser ?? && c.businOrderUser.nickname??>
						${c.businOrderUser.nickname!} </#if></th>
					<th><#if c.businOrderUser ?? && c.businOrderUser.telephone??>
						${c.businOrderUser.telephone!} </#if></th>
					<!--      <td><#if c.createtime?? >${c.createtime?string('yyyy-MM-dd HH:mm:ss')}</#if></td> -->
 					<td><#if c.purchaseOrLease?? &&  c.purchaseOrLease=="1">租赁 </#if>
 							<#if c.purchaseOrLease?? &&  c.purchaseOrLease=="2">购买</#if>	</td>

					<td>
					<@shiro.hasPermission name="13.2.1"> 
					<a href="${base}/businorder/detail?id=${c.id!}&businessid=${c.businessid!}" class="btn btn-primary">详情</a>
					<a href="${base}/businorder/goDeviceNumbers?orderCode=${c.orderCode!}" class="btn btn-primary">补录设备号</a> 
						</@shiro.hasPermission>
						
						<#if c.status==1> 
					   <a href="#" onclick="beginOrder('${c.id!}',${pagination.pageNo!})" class="btn btn-primary"> <span id="spanid3">开始处理 </span></a>
					    </#if>
					<#if c.status==25>
						  <a href="${base}/businorder/getExpress?orderCode=${c.orderCode!}&orderId=${c.id!}" class="btn btn-primary">发货</a>
					</#if> 
					<#if c.status==13 && c.purchaseOrLease=="1">
						 <a href="#"  onclick="beginBilling('${c.orderCode!}',${pagination.pageNo!},'${c.id!}')" class="btn btn-primary"> <span id="spanid1">开始计费 </span></a> 
					</#if>
					<#if c.status==13 && c.purchaseOrLease=="2">
						 <a href="#"  onclick="confirmReceipt(${pagination.pageNo!},'${c.id!}')" class="btn btn-primary"> <span id="spanid1">确认收货 </span></a> 
					</#if>
				<!-- 	 <#if c.status==10> 
					   <button type="submit" onclick="refundSuccess('${c.id!}')" id="s_${c.id!}" class="btn btn-success">同意退款</button>
						<button type="submit" onclick="refused('${c.id!}')" id="r_${c.id!}" class="btn btn-danger">拒绝退款</button> 
					</#if> 
					<#if c.isRefund??&&c.isRefund==1>
					  <a href="javascript:goods('${c.id!}')" id="${c.id}Refund" class="btn btn-primary">退货退款</a>
					  </#if>
					  -->
					    <#if c.status==22 && c.purchaseOrLease=="1"> 
					   <a href="#" onclick="confirmReturn('${c.id!}',${pagination.pageNo!})" class="btn btn-primary"> <span id="spanid2">确认归还 </span></a>
					    </#if>

					</td>
				</tr>


				</#list> <#if 0==pagination.totalCount>
				<tr>
					<td colspan="7" style="color: red">没有相关数据</td>
				</tr>
				</#if>

			</tbody>

		</table>
		<!--<span style="text-align: left"> <a href="#" class="btn btn-primary">新增</a></span>-->
		<#include "/view/admin/pagination.html"/>


	</div>
	<script>
    function setPage(pageNo,pageSize){
    	 var href = "${base}/businorder/list?";

         href+='orderCode='+$('#orderCode').val();
                 href+='&'


         href+='businessId='+$('#businessId').val();
                 href+='&'

     	  href+='phoneNo='+$('#phoneNo').val();
     			href+='&'

         href+='status='+$('#status').val();
                 href+='&'
              href+='equipmentSerNum='+$('#equipmentSerNum').val();
          href+='&'

         href+='createTimeStart='+$('#createTimeStart').val()+"&";
         href+='createTimeEnd='+$('#createTimeEnd').val();
         href+="&pageNo="+pageNo;
         href+="&pageSize="+pageSize;
         location.href=href;
    }
    function checkDelete(url){
        if (window.confirm("确认删除吗?")) {
            location.href=url;
        }
    }
    function goods(id){
        if (window.confirm("确认同意退款吗?")) {
            $('#' + id+"Refund").attr('disabled', true);
            location.href="${base}/czjrefund/goods.do?orderId="+id;
//            $.get("${base}/czjrefund/goods.do",
//                {orderId:id}, function (data, textStatus){
//                if('success'==textStatus||'SUCCESS'==textStatus){
//                    if(data.status==1){
//                        $('#'+id+'RefundSu').remove();
//                        $('#'+id+'RefundStatus').html('退款成功');
//                    }else{
//                        alert('');
//                    }
//                }else{
//
//                }
//            });
//            location.href="${base}/czjrefund/goods.do?orderId="+id;
        }
    }

    function refundSuccess(id){
        if (window.confirm("确认同意退款吗?")) {
            $('#s_' + id).attr('disabled', true);
            location.href="${base}/czjrefund/success.do?orderId="+id;
        }
    }
    function refused(id){
        if (window.confirm("确认拒绝退款吗?")) {
            $('#r_' + id).attr('disabled', true);
            location.href="${base}/czjrefund/refused.do?orderId="+id;
        }
    }
    
    
	//开始计费
 	function beginBilling(orderCode,pageNo,orderid){
 		

 		
 	      $.ajax({
 	            url:"${base}/businorder/beginBilling",
 	            type: "GET",
 	            data:{
 	            	"orderCode":orderCode,
 	            	"orderid":orderid
 	            },
 	           dataType:"json",
 	      	success: function(data){

 	            	if(data.status==1){
 	            		
 	            		window.location="${base}/businorder/list?pageNo="+pageNo;
 	            		
 	            	}else{
 	            		alert(data.msg);
 	            	}
 	            },
 	            error:function(data){
	                alert('error');
 	            }
 	        });
 	}

	//确认收货
 	function confirmReceipt(pageNo,orderid){
     $.ajax({
           url:"${base}/businorder/confirmReceipt",
           type: "GET",
           data:{
           	"id":orderid
           },
          dataType:"json",
     	success: function(data){

           	if(data.status==1){
           		
           		window.location="${base}/businorder/list?pageNo="+pageNo;
           		
           	}else{
           		alert(data.msg);
           	}
           },
           error:function(data){
              alert('error');
           }
       });
}
	
	function confirmReturn(id,pageNo){
		

		$.ajax({
	            url:"${base}/businorder/confirmReturn",
	            type: "GET",
	            data:{
	            	"id":id,
	            },
	           dataType:"json",
	      	success: function(data){

	            	if(data.status==1){
	            		window.location="${base}/businorder/list?pageNo="+pageNo;
	            		
	            	}else{
	            		alert(data.msg);
	            	}
	            },
	            error:function(data){
                alert('error');
	            }
	        });
	}
	
function beginOrder(id,pageNo){
		
	
		$.ajax({
	            url:"${base}/businorder/beginOrder",
	            type: "GET",
	            data:{
	            	"id":id,
	            },
	           dataType:"json",
	      	success: function(data){

	            	if(data.status==1){
	            		window.location="${base}/businorder/list?pageNo="+pageNo;
	            		
	            	}else{
	            		alert(data.msg);
	            	}
	            },
	            error:function(data){
                alert('error');
	            }
	        });
	}
</script>

</body>
</html>
